import Vue from "vue";
import VueRoute from "vue-router";
// 一级路由
/* import Home from "../views/Home";
import Login from "../views/Login"; */

// 路由组件的懒加载 也是同样调用import方法
const Home = () => {
  return import("../views/Home");
};

const Login = () => import("../views/Login");
// 二级路由
// import New from "../views/Home/components/New";
// import Game from "../views/Home/components/Game";
// import Movie from "../views/Home/components/Movie";

const New = () => import("../views/Home/components/New");
const Game = () => import("../views/Home/components/Game");
const Movie = () => import("../views/Home/components/Movie");

// 三级
const GameItem = () => import("../views/Home/components/Game/Item");


Vue.use(VueRoute);



export default new VueRoute({
  //设置路由模式为history模式!!!!
  mode: "history",
  routes: [
    {
      path: "/home",
      component: Home,
      //如果当前的路由设置有默认子路由,则不建议书写name命名路由
      // name: "Home",
      // 配置默认子路由
      redirect: "/home/new",
      // 二级路由
      children: [
        {
          path: "new",
          component: New,
          name: "news"
        },
        {
          path: "game",
          component: Game,
          name: "game",
          children: [
            {
              path: "item/:id/:title?",
              component: GameItem,
            }
          ]
        },
        {
          path: "movie",
          component: Movie,
          name: "movie"
        }
      ]
    },
    {
      path: "/login",
      component: Login
    },
    // 默认路由
    {
      path: "/",
      // 重定向的配置
      redirect: "/home"
    }
  ]
});